From 399bffa1e9ac5cc29822e934c73eafbca8d4636a Mon Sep 17 00:00:00 2001 From: "dan@guaranine.beaverton.ibm.com" Date: Wed, 23 Nov 2005 12:31:55 +0100 Subject: [PATCH] Add tests for bug #331 --- .../11_block_attach_shared_dom0.py | 32 +++++++++++++++++++ .../12_block_attach_shared_domU.py | 24 ++++++++++++++ tools/xm-test/tests/block-create/Makefile.am | 4 ++- 3 files changed, 59 insertions(+), 1 deletion(-) create mode 100644 tools/xm-test/tests/block-create/11_block_attach_shared_dom0.py create mode 100644 tools/xm-test/tests/block-create/12_block_attach_shared_domU.py diff --git a/tools/xm-test/tests/block-create/11_block_attach_shared_dom0.py b/tools/xm-test/tests/block-create/11_block_attach_shared_dom0.py new file mode 100644 index 0000000000..01b3a794d0 --- /dev/null +++ b/tools/xm-test/tests/block-create/11_block_attach_shared_dom0.py @@ -0,0 +1,32 @@ +#!/usr/bin/python + +# Copyright (C) International Business Machines Corp., 2005 +# Author: Dan Smith + +from XmTestLib import * + +# Mount /dev/ram0 + +s, o = traceCommand("mkfs /dev/ram0") +if s != 0: + FAIL("Unable to mkfs /dev/ram0") + +s, o = traceCommand("mkdir -p mnt"); +if s != 0: + FAIL("Unable to create ./mnt") + +s, o = traceCommand("mount /dev/ram0 mnt -o rw") +if s != 0: + FAIL("Unable to mount /dev/ram0 on ./mnt") + +# Now try to start a DomU with write access to /dev/ram0 + +domain = XmTestDomain(); +domain.configAddDisk("phy:/dev/ram0", "hda1", "w") + +try: + domain.start() + s, o = traceCommand("umount mnt") + FAIL("Bug #331: Started a DomU with write access to a rw mounted block device") +except DomainError, e: + s, o = traceCommand("umount mnt") diff --git a/tools/xm-test/tests/block-create/12_block_attach_shared_domU.py b/tools/xm-test/tests/block-create/12_block_attach_shared_domU.py new file mode 100644 index 0000000000..ba23a7f76c --- /dev/null +++ b/tools/xm-test/tests/block-create/12_block_attach_shared_domU.py @@ -0,0 +1,24 @@ +#!/usr/bin/python + +# Copyright (C) International Business Machines Corp., 2005 +# Author: Dan Smith + +from XmTestLib import * + +dom1 = XmTestDomain() +dom2 = XmTestDomain(dom1.getName() + "-2") + +dom1.configAddDisk("phy:/dev/ram0", "hda1", "w") +dom2.configAddDisk("phy:/dev/ram0", "hda1", "w") + +try: + dom1.start() +except DomainError, e: + FAIL("Unable to start domain") + +try: + dom2.start() + FAIL("Bug #331: Started a DomU with write access to an in-use block device") +except DomainError, e: + pass + diff --git a/tools/xm-test/tests/block-create/Makefile.am b/tools/xm-test/tests/block-create/Makefile.am index a9b01a6593..2578408b0f 100644 --- a/tools/xm-test/tests/block-create/Makefile.am +++ b/tools/xm-test/tests/block-create/Makefile.am @@ -8,7 +8,9 @@ TESTS = 01_block_attach_device_pos.test \ 06_block_attach_baddomain_neg.test \ 07_block_attach_baddevice_neg.test \ 08_block_attach_bad_filedevice_neg.test \ - 09_block_attach_and_dettach_device_check_data_pos.test + 09_block_attach_and_dettach_device_check_data_pos.test \ + 11_block_attach_shared_dom0.test \ + 12_block_attach_shared_domU.test DISABLED = -- 2.30.2